//
//  IGDrawListCell.m
//  jingdongfang
//
//  Created by BOE on 2018/5/22.
//  Copyright © 2018年 BOE-SBG-CTO. All rights reserved.
//

#import "IGDrawListCell.h"


@interface IGDrawListCell()

@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *deatilLabel;

@end

@implementation IGDrawListCell

+ (IGDrawListCell *)cellWithTable:(UITableView *)tableView {
    IGDrawListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"kIGDrawListCell"];
    if (!cell) {
        cell = [[IGDrawListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"kIGDrawListCell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}

- (void)createUI {
    _imgView = [UIImageView new];
    [self.contentView addSubview:_imgView];
    
    _nameLabel = [UILabel new];
    [self.contentView addSubview:_nameLabel];
    _nameLabel.font = [UIFont font18];
    _nameLabel.textColor = [UIColor c4Color];
    
    _deatilLabel = [UILabel new];
    [self.contentView addSubview:_deatilLabel];
    _deatilLabel.font = [UIFont font14];
    _deatilLabel.textColor = [UIColor c5Color];
    
    [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(0);
        make.width.height.mas_equalTo(75);
    }];
    
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.imgView.mas_right).mas_equalTo(24);
        make.top.mas_equalTo(14);
        make.height.mas_equalTo(20);
        make.right.mas_equalTo(20);
    }];
    
    [_deatilLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nameLabel.mas_left);
        make.bottom.mas_equalTo(17);
        make.height.mas_equalTo(15);
        make.right.mas_equalTo(self.nameLabel.mas_right);
    }];
}

- (void)setDrawModel:(IGDrawModel *)drawModel {
    if (_drawModel == drawModel) {
        return;
    }
    
    _drawModel = drawModel;
    [_imgView sd_setImageWithURL:[NSURL URLWithString:drawModel.image]];
    _nameLabel.text = drawModel.title;
    _deatilLabel.text = drawModel.content;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
